var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'integer',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'registerName',
        title: '设备申请人姓名',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'userType',
        title: '申请单位',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg',
        resolution: function (value) {
            if (value == 0) {
                return '个人';
            } else if (value == 1) {
                return '企业';
            }
        }
    }, {
        id: 'spouseName',
        title: '申请人配偶姓名/企业法人姓名',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg',
        resolution: function (value) {
            if (value == 0) {
                return '申请人配偶姓名';
            } else if (value == 1) {
                return '企业法人姓名';
            }
        }
    }, {
        id: 'spouseIdentification',
        title: '申请人配偶身份证号/企业法人身份证号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg',
        resolution: function (value) {
            if (value == 0) {
                return '申请人配偶身份证号';
            } else if (value == 1) {
                return '企业法人身份证号';
            }
        }
    }, {
        id: 'spousePhone',
        title: '申请人配偶电话号码/企业法人电话号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'address',
        title: '有效通信地址',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'registerPhone',
        title: '申请人电话',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'identification',
        title: '申请人身份证号/企业代码',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'password',
        title: '用户密码',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'operation',
        title: '操作',
        type: 'string',
        columnClass: 'text-center tpl-table-black-operation',
        headerStyle: 'color:grey; white-space:nowrap; padding: 0px 60px;',
        resolution: function (value, record, column, grid, dataNo, columnNo) { //此处的值（value）不直接显示
            var content = '';
            content += '<a href="#" onclick="loadPage(\'userInfo/' + record.id + '/select\');"> <i class="am-icon-pencil"></i>编辑</a> ';
            return content;
        }
    }];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    check: true,
    checkWidth: '37px',
    loadURL: 'userInfo/list',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    tools: '',
    pageSize: 10, //默认每页十条记录
    pageSizeLimit: [10, 20, 30] //分页选项：每页10、20\或者30条记录
};
var grid = $.fn.dlshouwen.grid.init(dtGridOption);


$(function () {
    grid.load();
    $('select').selected();
});

function search() {
    grid.parameters = new Object();
    grid.parameters['title'] = $("#title").val();
    grid.refresh(true);
}

function delteAll() {
    var checkId = getCheckAll(grid.getCheckedRecords());
    if (checkId != '') {
        del("userInfo/" + checkId + "/deleteBatch", search);
    } else {
        layer.msg('请选择要删除的数据', {
            icon: 3
        });
    }
}

